/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2006
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.continuousPointModel;

import java.io.Serializable;

import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;

/**
*A class representing an PolarPlaneStressPoint analysis model.
*
*@author Pitangueira, Roque, & CENOURA & Fuina,Jamile!!!
*@version 1.0
*@since September 2003
*/
public class PolarPlaneStressPoint implements ContinuousPointModel, Serializable  {

	private static final long serialVersionUID = 1L;

	/* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getInternalVariableOperator(IMatrix d, IMatrix d2, IVector n, IMatrix c) {
        IMatrix l = new IMatrix(6,6);
        l.setIdentity();
        return l;
    }

//     /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#modifyInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IMatrix)
//     */
//    public IMatrix modifyInternalVariableOperator(IMatrix e, IMatrix m) {
//        return e;
//    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getDualInternalVariableOperator(IMatrix e) {
    	 IMatrix d = new IMatrix(6,6);
         d.setZero();
         double G = e.getElement(3,3);
         double E = e.getElement(0,0);
         double ni = e.getElement(0,1);
         double alpha = e.getElement(3,1);
         d.setElement(0,0,(E/(1.0 - ni*ni)));
         d.setElement(0,3,(E*ni/(1.0 - ni*ni)));
         d.setElement(1,1,G + alpha);
         d.setElement(1,2,G - alpha);
         d.setElement(2,1,G - alpha);
         d.setElement(2,2,G + alpha);
         d.setElement(3,0,(E*ni/(1.0 - ni*ni)));
         d.setElement(3,3,(E/(1.0 - ni*ni)));       
         d.setElement(4,4,2.0*G);
         d.setElement(5,5,2.0*G);        
         return(d);
    }
    
//    /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#modifyDualInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, java.util.ArrayList)
//     */
//	public IMatrix modifyDualInternalVariableOperator(IMatrix e, GeometricProperties gps)	{
//		return e;
//	}

	/* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getNumberOfInternalVariables()
     */
    public int getNumberOfInternalVariables() {
        return 6;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getNumberOfDualInternalVariables()
     */
    public int getNumberOfDualInternalVariables() {
        return 6;
    }

//    /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesVector(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
//     */
//    public IVector getInternalVariablesVector(IVector a, IMatrix b) {
//    	IVector strainVector = new IVector(6);
//		strainVector.setElement(0, a.getElement(0)); 
//		strainVector.setElement(1, a.getElement(1));
//		strainVector.setElement(2, a.getElement(2));
//		strainVector.setElement(3, a.getElement(3));
//		strainVector.setElement(4, (-b.getElement(2,0)/(1 - b.getElement(2,0)))*(a.getElement(0)+a.getElement(3)));
//		strainVector.setElement(5, a.getElement(4));
//		return strainVector;
//    }
//
//    /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariablesVector(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
//     */
//    public IVector getDualInternalVariablesVector(IVector a, IMatrix b) {
//        return a;
//    }
//
//    /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesTensor(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
//     */
//    public IMatrix getInternalVariablesTensor(IVector a, IMatrix b) {
//		IMatrix Tensor = new IMatrix(6,6);
//		Tensor.setZero();
//        Tensor.setElement(0,0,a.getElement(0));
//        Tensor.setElement(0,1,a.getElement(1));
//        Tensor.setElement(1,0,a.getElement(2));
//        Tensor.setElement(1,1,a.getElement(3));
//        Tensor.setElement(2,2,(-b.getElement(2,0)/(1 - b.getElement(2,0)))*(a.getElement(0)+a.getElement(3)));
//        Tensor.setElement(3,5,a.getElement(4));
//        Tensor.setElement(4,5,a.getElement(5));        
//        return Tensor;
//    }
//
//    /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariablesTensor(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
//     */
//    public IMatrix getDualInternalVariablesTensor(IVector a, IMatrix b) {
//        return expandTensor(a);
//    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesDirLabels()
     */
    public String[] getInternalVariablesLabels() {
        String[] Dlabels = {"GAMAxx", "GAMAxy", "GAMAyx", "GAMAyy", "KxzLf", "KyzLf"};
        return Dlabels;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariablesDirLabels()
     */
    public String[] getDualInternalVariablesLabels() {
        String[] Dlabels = {"SIGMAxx", "SIGMAxy", "SIGMAyx", "SIGMAyy", "MIxz/Lf", "MIyz/Lf"};
        return Dlabels;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#expandVector(br.ufmg.dees.insane.util.IVector)
     */
    public IVector expandVector(IVector a) {
		IVector Vector = new IVector(18);
        Vector.setElement(0,a.getElement(0));
        Vector.setElement(1,a.getElement(1));
        Vector.setElement(3,a.getElement(2));
        Vector.setElement(4,a.getElement(3));
        Vector.setElement(11,a.getElement(4));
        Vector.setElement(14,a.getElement(5));
        return Vector;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#expandTensor(br.ufmg.dees.insane.util.IVector)
     */
    public IMatrix expandTensor(IVector a) {
		IMatrix Tensor = new IMatrix(6,6);
		Tensor.setZero();
        Tensor.setElement(0,0,a.getElement(0));
        Tensor.setElement(0,1,a.getElement(1));
        Tensor.setElement(1,0,a.getElement(2));
        Tensor.setElement(1,1,a.getElement(3));        
        Tensor.setElement(3,5,a.getElement(4));
        Tensor.setElement(4,5,a.getElement(5));        
        return Tensor;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#reduceVector(br.ufmg.dees.insane.util.IVector)
     */
    public IVector reduceVector(IVector a) {
		IVector Vector = new IVector(6);
        Vector.setElement(0,a.getElement(0));
        Vector.setElement(1,a.getElement(1));
        Vector.setElement(2,a.getElement(3));
        Vector.setElement(3,a.getElement(4));
        Vector.setElement(4,a.getElement(11));
        Vector.setElement(5,a.getElement(14));
        return Vector;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#reduceTensor(br.ufmg.dees.insane.util.IMatrix)
     */
    public IVector reduceTensor(IMatrix a) {
		IVector Vector = new IVector(6);
        Vector.setElement(0,a.getElement(0,0));
        Vector.setElement(1,a.getElement(0,1));
        Vector.setElement(2,a.getElement(1,0));
        Vector.setElement(3,a.getElement(1,1));
        Vector.setElement(4,a.getElement(3,5));
        Vector.setElement(5,a.getElement(4,5));
        return Vector;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getLabel()
     */
    public String getLabel() {
        return "PolarPlaneStressPoint";
    }
    
//    /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDOFLabels(int)
//     */
//    public ArrayList getDOFLabels(int n){
//		ArrayList <PointValues> al = new ArrayList<PointValues>();
//		PointValues spv = new StringPointValues();
//	    spv.addPointValue("Dx");
//	    spv.addPointValue("Dy");
//	    spv.addPointValue("MRz");
//		for(int i=0; i<n; i++) {
//			al.add(i,spv);
//		}
//		return al;
//	}
//    
//    /* (non-Javadoc)
//     * @see br.ufmg.dees.insane.analysisModel.PolarPlane#getPMatrix()
//     */
//    public IMatrix getPMatrix(){
//        IMatrix P = new IMatrix(6,6);
//		P.setZero();
//        P.setElement(0,0, 2.0/3.0);
//        P.setElement(3,3, 2.0/3.0);
//        P.setElement(0,3, -1.0/3.0);        
//        P.setElement(3,0, -1.0/3.0);        
//        P.setElement(1,1, 1.0/2.0);
//        P.setElement(1,2, 1.0/2.0);
//        P.setElement(2,1, 1.0/2.0);
//        P.setElement(2,2, 1.0/2.0);
//        P.setElement(4,4, 1.0);
//        P.setElement(5,5, 1.0);
//        return P;
//    }
//
//	public int getDominion() {
//		// TODO Auto-generated method stub
//		return 0;
//	}
//
//	public double getIntegrationFactor(IVector n, IMatrix cN, GeometricProperties gps) {
//		// TODO Auto-generated method stub
//		return 0;
//	}   

}
